package com.violet.domain.result;

import com.violet.utils.IdUtils;
import lombok.Data;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Data
@Accessors(chain = true)
public class OrderMessage {

    private String id;
    private String title;
    private String content;
    private String type;
    private String time;
    private Boolean isRead = false;

    private OrderMessage() {}

    private static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    public static OrderMessage buildOrderPaid(String orderId) {
        return new OrderMessage()
            .setId(IdUtils.getId("M"))
            .setTitle("待发货订单")
            .setContent("%s 等待发货".formatted(orderId))
            .setType("info")
            .setTime(formatter.format(LocalDateTime.now()));
    }

}
